/**
 * @description 文本框计算输入值长度
 * @param code
 * @param value
 * @returns {number}
 */
import GraphemeSplitter from 'grapheme-splitter'
export function textCount(code: string, value: string) {
  let backText = 0
  let splitter: any = null
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  splitter = new GraphemeSplitter()
  if (value) {
    backText = value.length
  }
  if (code) {
    eval(code)
  }
  return backText
}

/**
 * @description 数值parse
 * @param code
 * @param value
 * @returns {string}
 */
export function getParse(code: string, value: string) {
  let backText = null
  if (value) {
    backText = null
  }
  if (code) {
    eval(code)
  }
  return backText
}

/**
 * @description 数值format
 * @param code
 * @param value
 * @returns {string}
 */
export function getFormat(code: string, value: string | number | null) {
  let backText = ''
  if (value) {
    backText = ''
  }
  if (code) {
    eval(code)
  }
  return backText
}

/**
 * @description 表单验证
 * @param code
 * @param value
 * @returns {string}
 */
export function getInputValidationStatus(
  code: string,
  value: null | string | number | string[] | number[]
) {
  let backText = ''
  if (value) {
    backText = ''
  }
  if (code) {
    eval(code)
  }
  return backText
}

/**
 * @description 下拉框验证
 * @param value
 * @param option
 * @returns {boolean}
 */
export function getSelectFilter(value: string | null, option: object, code: string) {
  let backText = true
  if (backText) {
    backText = true
  }
  if (code) {
    eval(code)
  }
  return backText
}
